package com.youlu.campus.admin.item;

import com.youlu.campus.common.base.RestResult;
import com.youlu.campus.common.base.RestResultBuilder;
import com.youlu.campus.entity.ItemInfo;
import com.youlu.campus.entity.VO.req.ItemQueryReq;
import com.youlu.campus.service.item.ItemInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品管理
 */
@RestController
public class ItemInfoController {

    @Autowired
    private ItemInfoService itemInfoService;

    @PostMapping("/item/save")
    public RestResult save(@RequestBody  ItemInfo saveItemInfo){
        itemInfoService.saveOrUpdate(saveItemInfo);
        return RestResultBuilder.builder().success().data(null).build();
    }

    @PostMapping("/item/list")
    public RestResult list(@RequestBody ItemQueryReq itemQueryReq){
        return RestResultBuilder.builder().success().data(itemInfoService.list(itemQueryReq)).build();
    }

    @GetMapping("/item/detail")
    private RestResult detail(@RequestParam String id){
        return RestResultBuilder.builder().success().data(itemInfoService.detail(id)).build();
    }


}
